import 'package:camerawesome/camerawesome_plugin.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'remote_camera_logic.dart';

class RemoteCameraPage extends StatelessWidget {
  RemoteCameraPage({super.key});

  final GlobalKey _globalKey = GlobalKey();

  final logic = Get.put(RemoteCameraLogic());
  final state = Get.find<RemoteCameraLogic>().state;

  @override
  Widget build(BuildContext context) {
    return PopScope(
        canPop: false,
        onPopInvoked: (didPop) => (logic.onDidPop(didPop)),
        child: Scaffold(
          body: Container(
            color: Colors.white,
            child: CameraAwesomeBuilder.awesome(
              saveConfig: SaveConfig.photo(),
              sensorConfig: SensorConfig.single(
                sensor: Sensor.position(SensorPosition.back),
                flashMode: FlashMode.auto,
                aspectRatio: CameraAspectRatios.ratio_4_3,
                zoom: 0.0,
              ),
              enablePhysicalButton: true,
              bottomActionsBuilder: (state) {
                logic.setCameraState(state);
                return AwesomeBottomActions(
                  state: state,
                );
              },
              previewFit: CameraPreviewFit.contain,
              availableFilters: awesomePresetFiltersList,
            ),
          ),
        ));
  }
}
